//Button
var Button = Ext.extend(Ext.button.Button, {});

//Cycle
var Cycle = Ext.extend(Ext.button.Cycle, {});

//Split
var Split = Ext.extend(Ext.button.Split, {});


//Chart
var Chart = Ext.extend(Ext.chart.Chart, {});


//Panel
var Panel = Ext.extend(Ext.panel.Panel, {
	width : 400
});

//Store
var Store = Ext.extend(Ext.data.Store, {
	pageSize: 20,
	autoLoad: false
});

//TreeStore
var TreeStore = Ext.extend(Ext.data.TreeStore, {});

//Grid
var Grid = Ext.extend(Ext.grid.Panel, {});

//Viewport
var Viewport = Ext.extend(Ext.container.Viewport, {});

//Tree
var Tree = Ext.extend(Ext.tree.Panel, {});

//Menu
var Menu = Ext.extend(Ext.menu.Menu, {});

//Window
var Window = Ext.extend(Ext.window.Window, {});

//Form
var Form = Ext.extend(Ext.form.Panel, {});

//TabPanel
var TabPanel = Ext.extend(Ext.tab.Panel, {});

//SelectModel
var SelectModel = Ext.extend(Ext.selection.CheckboxModel, {});

//ShowMessage
var ShowMessage = function(txt) {
	Ext.example.msg(txt, '', '');
};

//Request
var RequestByUrl = function(url, params) {
	var res = "";
	Ext.Ajax.request( {
		url : url,
		async : false ,
		success : function(response) {
			if (response.responseText == "") {
				window.location.href="login.html?msg=您没有登录或登录超时，请重新登录！"; 
			}
			res = Ext.decode(response.responseText);
		},
		failure : function() {
			Ext.Msg.alert('错误', '操作异常！');
		},
		params: params
    });
	return res;
};

//FormSubmit
var FormSubmit = function(fom, url, params, callback) {
	fom.submit({
		clientValidation: true,
		params: params,
		url: url,
		waitTitle: '提示',
		waitMsg: '正在提交中...',
		success: function(form, action) {
//			Ext.Msg.alert('提示', action.result.msg);
			Ext.Show.msg(action.result.title, action.result.msg);
			if (callback != null) callback(action.result);
		},
		failure: function(form, action) {
			Ext.Msg.alert('提示', '操作异常！');
		}
	});
};

Ext.Show = function(){
    var msgCt;
    function createBox(t, s){
       return '<div class="msg"><h3>' + t + '</h3><p>' + s + '</p></div>';
    }
    return {
        msg : function(title, format){
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
            }
            var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, createBox(title, s), true);
            m.hide();
            m.slideIn('t').ghost("t", { delay: 2000, remove: true});
        },
        init : function(){}
    };
}();